package com.sanwu.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.sanwu.dto.SysUserDto;
import com.sanwu.service.SysUserService;
import com.sanwu.vo.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author hgh
 * @date 2025/3/5
 * @apiNote
 */

@Slf4j
@Component
@Api(tags = "用户端-用户信息接口")
@RestController("/user")
public class UserController extends BaseController {

    @Resource
    private SysUserService sysUserService;

    @PostMapping("/passWordLogin")
    @ApiOperation("密码登录")
    public AjaxResult passWordLogin(@RequestBody SysUserDto sysUserDto) {
        return sysUserService.passWordLogin(sysUserDto);
    }

    @PostMapping("/phoneMessageLogin")
    @ApiOperation("短信验证码登录")
    public AjaxResult phoneMessageLogin(@RequestBody SysUserDto sysUserDto) {
        return sysUserService.phoneMessageLogin(sysUserDto);
    }

    @GetMapping("/sendCheckCodeUser")
    @ApiOperation("发送短信验证码")
    public AjaxResult sendCheckCode() {
        return sysUserService.sendCheckCode();
    }

    @PostMapping("/getDetail")
    @ApiOperation("查看用户详情")
    public AjaxResult getDetail(@RequestBody SysUserDto sysUserDto) {
        return sysUserService.getDetail(sysUserDto);
    }

    @PostMapping("/updateUserInfo")
    @ApiOperation("修改用户信息")
    public AjaxResult updateUserInfo(@RequestBody SysUserDto sysUserDto) {
        return sysUserService.updateUserInfo(sysUserDto);
    }

    @PostMapping("/insertUser")
    @ApiOperation("注册用户")
    public AjaxResult insertUser(@RequestBody SysUserDto sysUserDto) {
        return sysUserService.insertUser(sysUserDto);
    }

}
